Type CalTextureCoordinate
	
	Field u:Float
	Field v:Float
	
	Method New()
		u = 0
		v = 0
	End Method
	
	Function FromUV:CalTextureCoordinate(uv:CalTextureCoordinate)
		Local nuv:CalTextureCoordinate = New CalTextureCoordinate
		
		nuv.u = uv.u
		nuv.v = uv.v
		Return nuv
		
	End Function
	
	Function FromCoords:CalTextureCoordinate(uu:Float,vv:Float)
		Local nuv:CalTextureCoordinate = New CalTextureCoordinate
		nuv.u = uu
		nuv.v = vv
		Return nuv
	End Function
	

End Type


Type CalTangentSpace

	Field tangent:CalVector
	Field crossFactor:Float
	
	Method New()
	
		tangent = New CalVector
		crossFactor = 0
		
	End Method
	
	Function FromVector:CalTangentSpace(t:CalVector,c:Float=0)
		Local ts:CalTangentSpace = New CalTangentSpace
		ts.tangent = CalVector.FromVector(t)
		ts.crossFactor = c
		Return ts
	End Function
	
	Function FromCoords:CalTangentSpace(xx:Float,yy:Float,zz:Float,c:Float=0)
		Local ts:CalTangentSpace = New CalTangentSpace
		ts.tangent = CalVector.FromCoords(xx,yy,zz)
		ts.crossFactor = c		
		Return ts
	End Function
	

End Type


Type CalInfluence

	Field boneId:Int
	Field weight:Float
	
	Method New()
		boneId = 0
		weight = 0
	End Method
	
	Function FromCoords:CalInfluence(b:Int,w:Float)
		Local ci:CalInfluence = New CalInfluence
		ci.boneId = b
		ci.weight = w
		Return ci
	End Function

End Type

Type CalPhysicalProperty

	Field weight:Float
	Field position:CalVector
	Field positionOld:CalVector
	Field force:CalVector
	
	Method New()
	
		weight = 0
		position = New CalVector
		positionOld = New CalVector
		force = New CalVector
					
	End Method
	
	Function FromWeight:CalPhysicalProperty(w:Float)
		Local pp:CalPhysicalProperty = New CalPhysicalProperty
		pp.weight = w
		Return pp
	End Function
	
	Function FromCoords:CalPhysicalProperty(p:CalVector,o:CalVector,f:CalVector,w:Float=0)
		Local pp:CalPhysicalProperty = New CalPhysicalProperty
		pp.weight = w
		pp.position = p
		pp.positionOld = o
		pp.force = f	
		Return pp
	End Function
	

End Type

Type CalVertex

	Field position:CalVector
	Field normal:CalVector
	Field vectorInfluence:CalInfluence[]
	Field collapseId:Int
	Field faceCollapseCount:Int
	
	Method New()
		
		position = New CalVector
		normal = New CalVector
		vectorInfluence = New CalInfluence[0]
		collapseId = 0
		faceCollapseCount = 0
		
	End Method
	
	Function FromVector:CalVertex(p:CalVector,n:CalVector=Null)
		Local v:CalVertex = New CalVertex
		v.position = CalVector.FromVector(p)
		If n = Null Then
			v.normal = New CalVector
		Else
			v.normal = CalVector.FromVector(n)
		EndIf
		v.vectorInfluence = New CalInfluence[0]
		v.collapseId = 0
		v.faceCollapseCount = 0		
		Return v
		
	End Function	
	

	
	Function FromData:CalVertex(p:CalVector,n:CalVector,i:CalInfluence[],c:Int=0,fcc:Int=0)
		Local v:CalVertex = New CalVertex
		v.position = CalVector.FromVector(p)
		v.normal = CalVector.FromVector(n)
		v.vectorInfluence = New CalInfluence[i.length] 'Should make a copy
		MemCopy(v.vectorInfluence,i,i.length)
		v.collapseId = c
		v.faceCollapseCount = fcc		
		Return v
	End Function
	
	Method assign(xx:Float,yy:Float,zz:Float)
	
		position = CalVector.FromCoords(xx,yy,zz)
	
	End Method

	Method assignVector(p:CalVector)
	
		position = CalVector.FromVector(p)
	
	
	End Method 	
	
End Type


Type CalFace

	Field vertexId:Int[3]
	
	Method New()
	
		vertexId[0] = 0
		vertexId[1] = 0
		vertexId[2] = 0
			
	End Method
	
	Function FromCoords:CalFace(v1:Int,v2:Int,v3:Int)
		Local f:CalFace = New CalFace
		f.vertexId[0] = v1
		f.vertexId[1] = v2
		f.vertexId[2] = v3
		Return f
	End Function
	
	Function FromFace:CalFace(f:CalFace)
		Local cf:CalFace = New CalFace
		cf.vertexId[0] = f.vertexId[0]
		cf.vertexId[1] = f.vertexId[1]
		cf.vertexId[2] = f.vertexId[2]	
		Return cf
	End Function
	
	Function FromArr:CalFace(vi:Int[])
		Local f:CalFace = New CalFace
		f.vertexId[0] = vi[0]
		f.vertexId[1] = vi[1]
		f.vertexId[2] = vi[2]		
		Return f
	End Function
	

End Type


Type CalSpring

	Field vertexId:Int[2]
	Field springCoefficient:Float
	Field idleLength:Float
	
	Method New()
	
		vertexId[0] = 0
		vertexId[1] = 0
		springCoefficient = 0
		idleLength = 0
	
	End Method
	
	
	Function FromCoords:CalSpring(id0:Int,id1:Int,sc:Float=0,l:Float=0)
		Local cs:CalSpring = New CalSpring
		cs.vertexId[0] = id0
		cs.vertexId[1] = id1
		cs.springCoefficient = sc
		cs.idleLength = l
		Return cs	
	End Function
	
	Function FromArr:CalSpring(id:Int[],sc:Float=0,l:Float=0)
		Local cs:CalSpring = New CalSpring
		cs.vertexId[0] = id[0]
		cs.vertexId[1] = id[1]
		cs.springCoefficient = sc
		cs.idleLength = l	
		Return cs		
	End	Function
	

End Type
